package accounts;



/**
   An account that earns interest at a fixed rate, locked for a number of months.
*/
	public class TimeDepositAccount extends BankAccount

	{
	private double interestRate;
	private double lockedPeriod;
	private double earlyDrawFee;
		/**
	      Constructs a bank account with a given interest rate and
	      a given lock-down period.
	      @param rate the interest rate
	      @param lock the number of locked months
	   */
	   public TimeDepositAccount(double rate, int lock, double fee) 
	   {  
	      interestRate = rate;
	      lockedPeriod = lock;
	      earlyDrawFee = fee;
	      
	   }
	   
	   public void withdraw(double amount) 
	   {  
	      // Now subtract amount from balance 
	      super.withdraw(amount); 
	      if (lockedPeriod>0)
	      {
	    	  super.withdraw(earlyDrawFee);
	      }
	   }

	   /**
	      Adds the earned interest to the account balance.
	   */
	   public void addInterest() 
	   {  
	      double interest = monthLow * interestRate / 100;
	      deposit(interest); 
	      lockedPeriod--;
	   }


}



